{-
.cpm 파일을 vtkImageData에서 로딩할 때 편한 형식의 파일로 변환한다.
-}

import System
import System.IO
import Data.IORef
import System.IO.Unsafe
import Data.Maybe
import Control.Monad
import Control.Concurrent
import Control.Concurrent.MVar
import Foreign.Ptr
import MyFFI
import Text.PrintScan as P -- install liboleg

conv s = if length s < 1000 then '1':s else show (length s * 87324)

test = do
	v <- newIORef "Hello?"
	forever $ do
		modifyIORef v conv
		readIORef v >>= putStr . show . length
		
test1 = do
  v <- newIORef 1
  forever $ do
      modifyIORef v (+1)
      readIORef v >>= \x-> return () -- if x `mod` 100000 == 0 then (putStrLn . show . length . show ) x else return ()

testInt _ 0 = print 0
testInt i n = do
	cIntGet i >>= \x->cIntSet i (x+n)
	when (n `mod` 10000 == 0) $ do
		print n
	testInt i (n-1)

test2 = print ts3

main = do
	(n:_) <- getArgs
	i <- cIntNew 0
	cIntSet i 1
	cIntGet i >>= print
	testInt i (read n)
	print "OK"